<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.shr.sys.util.CodeTableHelper"%>
<%@ taglib uri="http://upbase.com.cn/tags" prefix="shr"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<shr:html>
<%
	String ${tablePK} = request.getParameter("${tablePK}");
%>
<shr:header title="修改${headName}信息">
</shr:header>
<script type="text/javascript"> 
var ${tablePK} = "<%=${tablePK} %>";
var _curUptInfo = "";

$(document).ready(function() {
	 getInfo();
});

function getInfo(){
	var url = '${r'${path}'}/${tableModel}/${tableAliasFistUpper}Action!get${tableAliasFistUpper}Info.action?${tablePK}=' + ${tablePK};
	AppKit.postJSON(url, "", getInfoSuccess);
}

function getInfoSuccess(json){
	if (!AppKit.checkJSONResult(json)) {
		return;
	}

	_curUptInfo = json.data;
	
	 for(var index in _curUptInfo){
		  $("#"+index).val(_curUptInfo[index]);
	 }
}

function update(){
	var paramObj =	$("#updateform").serializeObject();
	var flag = $("#updateform").form('validate');
	paramObj["category_id"] = category_id;
	if(flag) {
		var url = "${r'${path}'}/${tableModel}/${tableAliasFistUpper}Action!update${tableAliasFistUpper}.action";
		AppKit.postJSON(url,paramObj,updateSuccess);
	}		
}

function updateSuccess(json){
	if(!AppKit.checkJSONResult(json)){
    	return;
    }
    
	AppKit.showMessage(json.message,"",function(){
		var data = AppKit.getOpenWinObj().window("options").data;
		if(data){
			data.datagrid("load");
		}
		AppKit.closeWindow();
	});
}

function closeWindow(){
	AppKit.closeWindow();
}
</script>
<body>
<form id="updateform" method="post" action="${r'${path}'}/${tableModel}/${tableAliasFistUpper}Action!update${tableAliasFistUpper}.action">
<table border="0" width="95%" >
	<tr align="center">
		<td>
			<table border="0" width="100%" cellpadding="0" cellspacing="0"  style="border-collapse:collapse" class="viewdatagrid">
		    <input id =${tablePK} name=${tablePK} type="hidden"/>
			<#list listColumn as column >
				<#if column_index%3==0>
			<tr>	
				</#if>
				<th >${column.label}：</th>
				<#if column.isTextField>
					<input class="easyui-validatebox" id="${column.id}" name="${column.name}"  <#if column.required!="">required="true"</#if> validType="length[1,${column.length}]"/>
				</#if>
				<#if column.isTextArea>
					<textarea  class="easyui-validatebox"  id="${column.id}" name="${column.name}"  <#if column.required!="">required="true"</#if>  rows="3"/>
				</#if>
				<#if column.isSelect>
					<select   class="easyui-validatebox" id="${column.id}" name="${column.name}"   <#if column.required!="">required="true"</#if> />
				</#if>
				<#if (column_index+1)%3==0>
			</tr>	
				</#if>
			</#list>
			<#if listColumn?size%3!=0>
			</tr>	
			</#if>
		 </table>
		</td>	
	</tr>
	
	<tr align="center" style="width: 100%">
		<td class="buttonline" style="text-align: center;padding: 10px 0px 10px 0px">
			<a href="javascript:update()"  class="update"><span>更新</span></a>
		         <a href="javascript:closeWindow()"  class="return" ><span>取消</span></a>
		</td>
	</tr>
</table>
</form>
</body>
</shr:html>
